package com.jt.www.enums.issue;


/**
 * 出单ifCode or 电子保单ifCode 映射
 */
public enum PolicyEnum {
    // 出单code  -- 类型(保单or发票)  --  电子保单|电子发票code  -- 备注
    YG_SZ_POLICY("20190515002", "POLICY","20190515012", "阳光实责校责电子保单"),
    YG_XZ_INVOICE("20190515002","INVOICE", "20190515022", "阳光实责校责电子发票"),
    YG_NEW_SZ_POLICY("20190726012", "POLICY","20190726003", "阳光实责校责电子保单"),
    YG_NEW_XZ_INVOICE("20190726012","INVOICE", "20190826022", "阳光实责校责电子发票"),
    YG_SP_POLICY("20190805002","POLICY","20190805003","阳光食品电子保单"),
    YG_SP_INVOICEY("20190805002","INVOICE","20190826044","阳光食品电子发票"),
    ZH_SZ_XZ_POLICY("20190731001","INVOICE","20190726008","中华联合实责校责电子保单"),
    TP_SZ_XZ_POLICY("20190726017","POLICY","20190726008","太平实责校责电子保单"),
    TP_SZ_XZ_INVOICE("20190726017","INVOICE","202007141606280","太平实责校责电子发票"),
    YN_WXB_POLICY("20200312002","POLICY","20200312004","云南学平险电子保单"),
    JN_WXB_POLICY("202007231708310","POLICY","202007251346580","济南学平险电子保单"),
    HN_WXB_POLICY("202008271514410","POLICY","20190516016","河南学平险电子保单"),
    DZ_SZ_INVOICE("20190518001","INVOICE","20190518021","大地实责校责电子发票"),
    DZ_SP_INVOICE("20190802002","INVOICE","20190518021","大地食品险电子发票"),
    GS_SZ_INVOICE("20190827001","INVOICE","20190518021","国寿实责校责电子发票"),
    GS_SP_INVOICE("20190909101","INVOICE","20190518021","国寿食品电子发票"),
    YN_XP_POLICY("202101201139110","POLICY","20190516016","云南学平电子保单");


    private String ifCode;  //
    private String policyType;
    private String policyIfCode;
    private String desc;

    PolicyEnum(String ifCode, String policyType, String policyIfCode, String desc) {
        this.ifCode = ifCode;
        this.policyType = policyType;
        this.policyIfCode = policyIfCode;
        this.desc = desc;
    }

    /**
     * 根据ifCode和类型获取对应电子保单或电子发票接口ifCode
     *
     * @param ifCode
     * @return
     */
    public static String getPolicyOrInvoiceByIfCode(String ifCode,String policyType) {
        for (PolicyEnum issueEnum : PolicyEnum.values()) {
            if (issueEnum.ifCode.equals(ifCode) && issueEnum.policyType.equals(policyType) ) {
                return issueEnum.policyIfCode;
            }
        }
        return "";
    }

    /**
     * 通过ifCode获取对应枚举值
     *
     * @param ifCode
     * @return
     */
    public static PolicyEnum getIssueEnum(String ifCode) {
        for (PolicyEnum issueEnum : PolicyEnum.values()) {
            if (issueEnum.ifCode.equals(ifCode)) {
                return issueEnum;
            }
        }
        return null;
    }

    public String getIfCode() {
        return ifCode;
    }

    public String getPolicyType() {
        return policyType;
    }

    public String getPolicyIfCode() {
        return policyIfCode;
    }

    public String getDesc() {
        return desc;
    }
}
